<?php

class Reservations_Detail_View {

    private $reservation_id;

    function __construct($reservation_id) {
        $this->reservation_id = $reservation_id;
    }

    public function toString() {
        $view_wrapper = new Div_Container('id', 'reservations-wrapper');
        $heading = new Div_Container('id', 'View_Heading');
        $heading->addContent('<h1>Reservation Details Page</h1></br></br>');
        $body = new Div_Container('id', 'reservations-body');
        $user_div = new Div_Container('id', 'res-detail-user-info');
        $resource_div = new Div_Container('id', 'res-detail-resource-info');
        $reservation_div = new Div_Container('id', 'res-detail-reservation-info');
        
        
        $reservation = new Reservation();
        $reservation = ReservationDB::getReservationByID($this->reservation_id);

        $note = $reservation->getReservation_note();
        $timestamp = $reservation->getReservation_timestamp();
        $resource_id = $reservation->getResource_id();
        $resource_type_id = $reservation->getResource_type_id();
        $slot_date = $reservation->getSlot_date();
        $slot_id = $reservation->getSlot_id();
        $slots_group_id = $reservation->getSlots_group_id();
        $user_id = $reservation->getUser_id();

        $slot = SlotDB::getSlotByID($slot_id);
        $resource = ResourceDB::getResourceByID($resource_id);
        $resource_type = ResourceTypeDB::getResourceTypeByID($resource->getResource_type_id());
        $user = UserDB::getUserByID($user_id);
        
        $resource_div->addContent('<h2 class="title">Resource Info: </h2></br>' . 
                '<p><span class="subtitle">Resource ID:</span> ' . $resource->getResource_id() . '</p>' .
                '<p><span class="subtitle">Resource Name:</span> ' . $resource->getResource_name() . '</p>'.
                '<p><span class="subtitle">Resource Type:</span> ' . $resource_type->getResource_type_name() . '</p>'.
                '<p><span class="subtitle">Resource Unique Identifier:</span> ' . $resource->getResource_identifier() . '</p>'.
                '<p><span class="subtitle">Resource Hour Rent Price:</span> ' . $resource->getResource_hour_rent_price() . '</p>'.
                '<p><span class="subtitle">Resource Note:</span> ' . $resource->getResource_note() . '</p></br></br>');
                
        $user_div->addContent('<h2 class="title">User Info: </h2></br>' . 
                '<p><span class="subtitle">User ID:</span> ' . $user->getUser_id() . '</p>' .
                '<p><span class="subtitle">User Name:</span> ' . $user->getName() . '</p>'.
                '<p><span class="subtitle">Email:</span> ' . $user->getEmail() . '</p>'.
                '<p><span class="subtitle">Address:</span> ' . $user->getAddress() . '</p>'.
                '<p><span class="subtitle">Phone:</span> ' . $user->getPhone() . '</p></br></br>');
                
        
        $reservation_div->addContent('<h2 class="title">Reservation Info: </h2></br>' . 
                '<p><span class="subtitle">Reservation ID:</span> ' . $reservation->getReservation_id() . '</p>' .
                '<p><span class="subtitle">Time:</span> ' . $slot->getSlot_time_from() . ' to ' . $slot->getSlot_time_to() . '</p>'.
                '<p><span class="subtitle">Date:</span> ' . $reservation->getSlot_date() . '</p>'.
                '<p><span class="subtitle">Reservation Timestamp:</span> ' . $reservation->getReservation_timestamp() . '</p>'.
                '<p><span class="subtitle">Reservation Note:</span> ' . $reservation->getReservation_note() . '</p></br></br>');
                
        
        $body->addContent($resource_div->toString() . $user_div->toString() . $reservation_div->toString());
        $view_wrapper->addContent($heading->toString());
        $view_wrapper->addContent($body->toString());

        return $view_wrapper->toString();
    }

}

?>
